<?php

namespace App\Http\Controllers\Wx;

use App\Setting;
use EasyWeChat\Foundation\Application;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    //
    public function index(Request $request){
        $options = [
            'debug'  => false,
            'app_id' => Setting::getConfig('app_id','微信配置'),
            'secret' => Setting::getConfig('secret','微信配置'),
            'token'  => Setting::getConfig('token','微信配置'),
            'log' => [
                'level' => 'debug',
                'file'  => '/tmp/easywechat.log', // XXX: 绝对路径！！！！
            ],
        ];
        $app = new Application($options);
        $response = $app->server->serve();
        return $response; // Laravel 里请使用：return $response;
    }
}
